package cn.northsea.mapper;

import cn.northsea.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.sql.Date;
import java.util.List;

@Repository
public interface WarehouseMapper {


    List<WarehouseProductVo> findWarehouseProductAll(@Param("likename") String likename);

    List<WarehouseOutVo> WarehouseOutList(@Param("likename") String likename, @Param("start") String start, @Param("end") String end);

    List<WarehouseInVo> WarehouseInList(@Param("likename") String likename, @Param("start") String start, @Param("end") String end);

    List<WarehouseMaterialVo> findWarehouseMaterialAll(@Param("likename") String likename);

    @Update("update erp_warehouse_material SET warehouse_material_quantity = warehouse_material_quantity - #{materialQuantity}  " +
            "WHERE material_id=#{materialId}")
    void updateWarehouseMaterial(@Param("materialId") Integer materialId, @Param("materialQuantity") Double materialQuantity);

    @Insert("insert into erp_warehouseout values (null,#{materialId},null,#{materialQuantity},#{date},#{warehouseId})")
    void addWarehouseOut(@Param("materialQuantity") Double materialQuantity, @Param("materialId") Integer materialId, @Param("date") Date date, @Param("warehouseId") Integer warehouseId);

    @Update("update erp_get_material set status = 1 where get_material_id = #{getMaterialId}")
    void status(Integer getMaterialId);

    @Select("select * from erp_warehouse_material where material_id = #{value}")
    WarehouseMaterial getQuantityByMid(Integer materialId);


    @Select("select * from erp_warehouse_material where material_id = #{value}")
    List<WarehouseMaterial> findWarehouseMaterialByMid(Integer materialId);

    @Update("update erp_get_material set status = 1 where get_material_id = #{value}")
    void updateGetMaterialStatus(Integer getMaterialId);
}
